<template>
	<view class="xieyi" v-html="content">
	</view>
</template>

<script>
	import httpPath from '@/static/js/path.js';
	import {getlogin} from '@/static/js/login.js';
	
	export default {
		data() {
			return {
				content:""
			}
		},
	    onPageScroll(e) {
	    	//兼容iOS端下拉时顶部漂移
	    	this.headerPosition = e.scrollTop>=0?"fixed":"absolute";
	    	this.headerTop = e.scrollTop>=0?null:0;
	    	this.statusTop = e.scrollTop>=0?null:-this.statusHeight+'px';
	    },
		onLoad() {
			this.user = getlogin();
			if(!this.user.islogin){
				uni.showModal({
				   showCancel:false,
				   content:"您还没有登录，请登录"
				})
				uni.navigateTo({
					url:"../public/login"
				})
			}
	        this.getdata()
		},
		methods: {
	        getdata(){
				uni.request({
				    url: httpPath.filePath+'/api.php/index/login/aboutUs', //短信验证码。
				    method:'POST',
				    header:{'content-type':'application/x-www-form-urlencoded'},
				    data: {id:1},
				    success: (res) => {
				         if(res.data.code && res.data.code=="200"){
				             // this.content=res.data.result.content
							 var richtext=res.data.result.content;
							 const regex = new RegExp('<img', 'gi');
							 // 判断是否头图片
							 if(richtext.indexOf('img') != -1){
							     richtext= richtext.replace(regex, `<img style="max-width: 100%;border-radius:5px"`);
							 }
							 this.content = richtext;
				         }
				    }
				}); 
			}   
		}
	}
</script>

<style>
	@import "../../colorui/main.css";
	.xieyi{font-size: 14px;line-height: 25px;padding: 5px;}
	.xieyi p{color: #666666;}
	.xieyi h1{font-size:16px;font-weight: bold;}
</style>
